from PySide6.QtWidgets import QMainWindow
from PySide6.QtCore import QThread, Signal

from log import logger


class PreviewWorker(QThread):
    done = Signal()

    def __init__(self, ui: QMainWindow):
        super().__init__()
        self.ui = ui

    def run(self):
        logger.info('Start PreviewWorker')

        if not self.ui.tab:
            logger.info('Preview Split.')
            self.ui.preview_split()
        else:
            logger.info('Preview Merge.')
            self.ui.preview_merge()

        self.done.emit()
        logger.info('End PreviewWorker')


class StartWorker(QThread):
    done = Signal()

    def __init__(self, ui):
        super().__init__()
        self.ui = ui

    def run(self):
        logger.info('Start StartWorker')

        if not self.ui.tab:
            self.ui.start_split()
        else:
            self.ui.start_merge()

        self.done.emit()
        logger.info('End StartWorker')